PATH
WebObjects 4.5 Documentation >
Getting Started With Direct to Java Client
The Rule System
The rule system is a private system that's provided by the com.apple.yellow.directtoweb package (it's the same rule system as the one used by Direct to Web). You never need to access it directly; the EOControllerFactory takes care of all interactions with the rule system. Nevertheless, it's important to understand the basics of the rule system and of how the controller factory interacts with it.
All the information about how to configure a Direct to Java Client application is stored in the form of rules. A rule has a key, a condition that must be true for the rule to "fire", a value, and a priority. The rule system evaluates requests as follows:
- The controller factory makes a request to the rule system by specifying a key.
- The rule system identifies the rules whose key is the same as the request key.
- It then evaluates the conditions of the matching rules to see which can fire.
- Of the rules that can fire, the rule system fires the one with the highest priority, returning the value for the rule's key.
To evaluate requests, the rule system needs information about the state of the client application. In addition to specifying a key, the controller factory also provides key-value pairs of state information that the rule system can use to evaluate rules' conditions. For example, the rule system might need to know what task the client application is attempting to perform (query, list, or form) and the entity on which the client application is operating.
The controller factory packages all rule system input--the request key and the key-value pairs of state information--into a dictionary known as a specification. The following are examples of specifications:
- question = window, task = queryWindow
- entity = Movie, question = window, task = form
- entity = Studio, question = modalDialog, task = select
A specification always contains a "question" entry, which contains the request key. The request keys in the above specifications are "window", "window", and "modalDialog", respectively.
The rule system stores the key-value pairs of state information in a D2WContext object. The D2WContext's whole purpose is to keep track of state as a page is generated. Initially the D2WContext is filled with state information provided by the controller factory. As the rule system processes the request, however, the system adds more and more state.
© 1999 Apple Computer, Inc. – (Draft. Last updated 05 Jan 00)